//
//  WelcomeTools.m
//  AiShangJinFuSalesman
//
//  Created by AiShangTong on 2017/7/5.
//  Copyright © 2018年 AiShangTong. All rights reserved.
//

#import "WelcomeTools.h"

#define HFQVersionKey @"HFQVersion"

#define BKapperKey @"HFQApperKey"//保存指定的版本;

#warning 确定哪个版本出引导页
#define BKapperVersion @"100"  //保存哪个版本引导页更新了

@implementation WelcomeTools

+(BOOL)AppearGuidePage{
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
    currentVersion = [currentVersion stringByReplacingOccurrencesOfString:@"." withString:@""];
    NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:HFQVersionKey];
    
    NSUserDefaults *userD = [NSUserDefaults standardUserDefaults];
    NSString *jiaoYanAPP = [userD objectForKey:@"ChuShiHuaWeiZhengChangAPP_Mao"];
    if ([jiaoYanAPP isEqualToString:@"999"]) {
        
        return YES;
    }
    //如果用户安装了
    if (lastVersion.length) {
        //获取上次更新引导页的版本;
        NSString *apper = [[NSUserDefaults standardUserDefaults]objectForKey:BKapperKey];
        //如果指定的版本 等于现在的版本,并且是第一次显示;
        if ([BKapperVersion isEqualToString:currentVersion] && ![apper isEqualToString:BKapperVersion]) {
            [[NSUserDefaults standardUserDefaults]setObject:BKapperVersion forKey:BKapperKey];//保存指定的版本,第二次进入的时候就不需要显示了;
            [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:HFQVersionKey];
            return YES;
        } else { //指定的版本不等于现在的版本,不显示;
            [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:HFQVersionKey];
            return NO;
        }
        
    } else { //如果用户没安装,进入引导页;
        [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:HFQVersionKey];
        [[NSUserDefaults standardUserDefaults]setObject:BKapperVersion forKey:BKapperKey];//保存指定的版本,第二次进入的时候就不需要显示了;
        return YES;
    }
    
}

@end
